home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / ucrasm27.zip / TEST.ZIP / TESTARGS.ASM < prev    next >
Assembly Source File  |  1991-10-24  |  2KB  |  130 lines

  1.         include        stdlib.a
  2.         includelib     stdlib.lib
  3. ;****************************************************************************
  4. ;
  5. ; T  E  S  T       S  U  I  T  E      F  O  R
  6. ;
  7. ;
  8. ; R  A  N  D  Y      H  Y  D  E ' S     S  T  A  N  D  A  R  D
  9. ;
  10. ; L  I  B  R  A  R  Y     F  O  R     A  S  S  E  M  B  L  Y
  11. ;
  12. ; L  A  N  G  U  A  G  E     P  R  O  G  R  A  M  M  E  R  S
  13. ;
  14. ;****************************************************************************
  15. ;
  16. ;
  17. ; Global variables go here:
  18. ;
  19. StdData        segment    para public 'sldata'
  20.         extrn    fpacc:byte
  21. StdData        ends
  22. ;
  23. ;
  24. dseg        segment    para public 'data'
  25. ;
  26. MemAvail    dw    ?
  27. dseg        ends
  28. ;
  29. ;
  30. ;
  31. ;
  32. cseg        segment    para public 'code'
  33.         assume    cs:cseg, ds:dseg
  34. ;
  35. ;
  36. lesi        macro    adrs
  37.         mov     di, seg adrs
  38.         mov    es, di
  39.         lea    di, adrs
  40.         endm
  41. ;
  42. ldxi        macro    adrs
  43.         mov    dx, seg adrs
  44.         lea    si, adrs
  45.         endm
  46. ;
  47. ; Variables that wind up being used by the standard library routines.
  48. ; The MemInit routine uses "PSP" and "zzzzzzseg" labels.  They must be
  49. ; present if you intend to use getenv, MemInit, malloc, and free.
  50. ;
  51. ;
  52.         public    PSP
  53. PSP        dw    ?
  54. ;
  55. cr        equ    13
  56. lf        equ    10
  57. ;
  58. ;
  59. ; Main is the main program.  Program execution always begins here.
  60. ;
  61. Main        proc
  62.         mov    cs:PSP, es        ;Save pgm seg prefix
  63.         mov    ax, seg dseg        ;Set up the segment registers
  64.         mov    ds, ax
  65.         mov    es, ax
  66.         mov    dx, 0            ;Allocate all available RAM.
  67.         MemInit
  68.         mov    MemAvail, cx
  69.         printf
  70.         db    "There are %x paragraphs of memory available."
  71.         db    cr,lf,lf,0
  72.         dd    MemAvail
  73. ;
  74. ;
  75. ;
  76. ;***************************************************************************
  77. ;
  78. ; Test the Argc and Argv functions:
  79. ;
  80.         print
  81.         db    "This routine has ",0
  82.         argc
  83.         mov    ax, cx
  84.         puti
  85.         print
  86.         db    " command line arguments",cr,lf,0
  87. ;
  88.         jcxz    Quit
  89. PrintArgs:    print
  90.         db    "Argument #",0
  91.         mov    ax, cx
  92.         puti
  93.         print
  94.         db    " is: ",0
  95.         argv
  96.         puts
  97.         free
  98.         putcr
  99.         dec    cx
  100.         jnz    PrintArgs
  101. ;
  102. ;***************************************************************************
  103. ;
  104. Quit:        mov     ah, 4ch
  105.         int     21h
  106. ;
  107. ;
  108. Main        endp
  109. ;
  110. ;
  111. ;
  112. cseg            ends
  113. ;
  114. ;
  115. ; Allocate a reasonable amount of space for the stack (2k).
  116. ;
  117. sseg        segment    para stack 'stack'
  118. stk        db    256 dup ("stack   ")
  119. sseg        ends
  120. ;
  121. ;
  122. ;
  123. ; zzzzzzseg must be the last segment that gets loaded into memory!
  124. ;
  125. zzzzzzseg    segment    para public 'zzzzzz'
  126. LastBytes    db    16 dup (?)
  127. heap        db    1024 dup (?)
  128. zzzzzzseg    ends
  129.         end    Main
  130.